using MySqlConnector;

namespace Front;

public partial class Login : Form
{
    public Login()
    {
        InitializeComponent();
    }

    public void button1_Click(object sender, EventArgs e)
    {
        using var connection = new MySqlConnection("Server=localhost;Database=front;Uid=root;Pwd=root");
        connection.Open();
        string sql = "SELECT * FROM admin_info where admin_account = @admin_account and admin_password = @pwd;";
        using var command = new MySqlCommand(sql,connection);
        string account = this.textBox1.Text;
        string password = this.textBox2.Text;
        object MD5Helper;
        string pwd = MD5Helper.GetMDS(password);
        command.Parameters.AddWithValue("account", account);
        command.Parameters.AddWithValue("pwd", pwd);
        using var reader = command.ExecuteReader();
        if (reader.HasRows)
        {
            MainForm mainForm = new MainForm();
            mainForm.Show();
            this.Hide();
        }
        else
        {
            
        }
        while (reader.Read())
            Console.WriteLine(reader.GetInt32(0));
    }

    public class MainForm
    {
    }
}

public class LoginImpl : Login
{
}